package com.budwk.app.sqfwV2.enums.centuryCitySafe;

import com.budwk.app.sqfwV2.dto.dto.SafeCheckTaskPdfDTO;
import com.budwk.app.sqfwV2.dto.dto.dayingRoad.ProblemParamDTO;
import lombok.Getter;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 世纪城安全排查13个问题
 */
@Getter
public enum CenturyCitySafeProblemEnum {

    ONE("1","isHydrantBlocked", "false", "1.消防栓是否存在遮挡、圈占现象"), //1
    TWO("2","isHydrantOperational", "true", "2.消防栓是否能正常使用"),//2
    THREE("3","isExtinguisherExpiredOrDamaged", "false", "3.灭火器有无过期或损坏等"),//3
    FORE("4","isAbleToUseFireExtinguisher", "true", "4.灭火器员工是否会使用"),//4
    FIVE("5","isUnauthorizedElectricGasConnection", "false", "5.电、气线路是否存在私搭乱接现象"),//5
    SIX("6","isExposedWiringGasLines", "false", "6.电、气线路是否存在裸露现象"),//6
    SEVEN("7","isThereAnyBlockage", "true", "7.安全出口是否畅通"),//7
    EIGHT("8","residentialFlag", "false", "8.是否存在夹层住人情况"),//8
    NINE("9","whetherFlamExplosive", "false", "9.是否生产、存储易燃易爆品"),//9
    TEN("10","isGasAlarmInstalled", "true", "10.是否安装燃气报警器"),//10
    ELEVEN("11","isProperlyInstalledGasAlarm", "true", "11.燃气报警器是否规范安装燃气报警器是否规范安装"),//11
    TWELVE("12","isNewFuelUsed", "false", "12.是否使用新型燃料(如:醇基)"),//12
    THIRTEEN("13","isConstructingFloors", "false", "13.是否自行搭建楼层"); // 13

    private final String number;

    private final String code;

    private final String defaultValue;

    private final String desc;

    CenturyCitySafeProblemEnum(String number, String code, String defaultValue, String desc) {
        this.number = number;
        this.code = code;
        this.defaultValue = defaultValue;
        this.desc = desc;
    }

    /**
     * 获取问题的默认值
     * @return
     */
    public static Map<String, String> getDefaultValues() {
        return Arrays.stream(values()).collect(Collectors.toMap(CenturyCitySafeProblemEnum::getCode, CenturyCitySafeProblemEnum::getDefaultValue));
    }

    /**
     * 获取需要整改的所有问题(12个问题) （有序数据）
     */
    public static Map<String, ProblemParamDTO> getProblemValues(SafeCheckTaskPdfDTO roadPdfDTO) {
        Map<String, ProblemParamDTO> map = new LinkedHashMap<>();
        map.put(ONE.getCode(), roadPdfDTO.getIsHydrantBlocked());  //1 消防栓是否存在遮挡、圈占现象
        map.put(TWO.getCode(), roadPdfDTO.getIsHydrantOperational());  //2 消防栓是否能正常使用
        map.put(THREE.getCode(), roadPdfDTO.getIsExtinguisherExpiredOrDamaged());  //3 灭火器有无过期或损坏等
        map.put(FORE.getCode(), roadPdfDTO.getIsAbleToUseFireExtinguisher());  //4 灭火器员工是否会使用
        map.put(FIVE.getCode(), roadPdfDTO.getIsUnauthorizedElectricGasConnection());  //5 电、气线路是否存在私搭乱接现象
        map.put(SIX.getCode(), roadPdfDTO.getIsExposedWiringGasLines());  //6 电、气线路是否存在裸露现象
        map.put(SEVEN.getCode(), roadPdfDTO.getIsThereAnyBlockage());  //7 安全出口是否畅通
        map.put(EIGHT.getCode(), roadPdfDTO.getResidentialFlag());  //8 是否存在夹层住人情况
        map.put(NINE.getCode(), roadPdfDTO.getWhetherFlamExplosive());  //9 是否生产、存储易燃易爆品
        map.put(TEN.getCode(), roadPdfDTO.getIsGasAlarmInstalled());  //10  是否安装燃气报警器
        map.put(ELEVEN.getCode(), roadPdfDTO.getIsProperlyInstalledGasAlarm());  //11  燃气报警器是否规范安装
        map.put(THIRTEEN.getCode(), roadPdfDTO.getIsConstructingFloors());  //13  是否自行搭建楼层
        return map;
    }

    /**
     * 获取所有问题的默认值
     */
    public static Map<String, ProblemParamDTO> getAllProblemValues(SafeCheckTaskPdfDTO roadPdfDTO) {
        Map<String, ProblemParamDTO> map = getProblemValues(roadPdfDTO);
        map.put(TWELVE.getCode(), roadPdfDTO.getIsNewFuelUsed());
        return map;
    }

    public static Map<String, ProblemParamDTO> sortExistProblemMap(Map<String, ProblemParamDTO> existProblemMap) {
        Map<String, ProblemParamDTO> map = new LinkedHashMap<>();
        if (existProblemMap == null || existProblemMap.size() == 0) {
            return map;
        }
        for (CenturyCitySafeProblemEnum e : values()) {
            ProblemParamDTO p = existProblemMap.get(e.getCode());
            if (p != null) {
                map.put(e.getCode(), p);
            }
        }
        return map;
    }
}
